﻿<%--028D151A4C468C85C4390F69A430BEA8131793115441994623--%>
<%@ Page Language="C#" Inherits="XinYeSoft.VIP.WebSite.PayZCZC" %><%@ Import Namespace="XinYeSoft.WebCommonLibrary" %><%
 DirRelVirPath = "~/Templates/Cont/";
this.SubmitFillUsers(); %>
<script runat="server">
protected override void OnLoad(System.EventArgs e)
{
this.DirRelVirPath = "~/Templates/Cont/";
base.OnLoad(e);
}
</script><!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
<meta name="keywords" content="<%=this.MetaKey%>" />
<meta name="description" content="<%=this.MetaDesc%>" />
<%=this.HeadHtml%>
<title><%=this.PageTitle%></title>
<link rel="shortcut icon" href="<%=this.Root%>/favicon.ico" />
<link rel="stylesheet" href="<%=this.Root%>/Assets/Styles/style.css">

<%
 if (this.PreferredDomain != "") { %>
<link rel="canonical" href="<%=this.PreferredDomain%>" />
<%
 } %>

    <link rel="stylesheet" type="text/css" href="<%=this.Root%>/Assets/Styles/payment.css"/>
    	
	<script src="<%=this.Root%>/Assets/Scripts/jquery-1.11.0.js" type="text/javascript" charset="utf-8"></script>
</head>

<body>
    
    <div class="payment">
		<div class="top">
			<div class="top-title">
				<div class="clearfix">
					<p class="p1">支持金额</p>
					<p class="p2">还差<span><%=this.ToText(this.NeedSum)%></span>元</p>
				</div>
			</div>
			<div class="top-list">
				<div class="top-item active">
					<input type="button" id="" name="88" value="88元" />
				</div>
				<div class="top-item">
					<input type="button" id="" name="128" value="128元" />
				</div>
				<div class="top-item">
					<input type="button" id="" name="188" value="188元" />
				</div>
				<div class="top-item">
					<input type="button" id="" name="288" value="288元" />
				</div>
			</div>
			<div class="top-list">
				<div class="top-item">
					<input type="button" id="" name="666" value="666元" />
				</div>
				<div class="top-item">
					<input type="button" id="" name="888" value="888元" />
				</div>
				<div class="top-item">
					<input type="button" id="" name="999" value="999元" />
				</div>
				<div class="top-item">
					<input type="button" id="" name="1888" value="1888元" />
				</div>
			</div>
			<div class="top-other">
				<input id="top-other-button" placeholder="0.00" type="number" name="" id="" value="" />
				<span class="top-other-titel">其他金额：</span>
			</div>
		</div>
		<div class="con">
			<textarea placeholder="<%=this.CurProject.ZCRemark%>" id="tbZcRemark" rows="" cols=""><%=this.CurProject.ZCRemark%></textarea>
		</div>
		<div class="submit">
            <span class="submit-button">合计： <span class="submit-money">88</span>元 立即付款</span>
		</div>
	</div>
	<script type="text/javascript">
        var num = 88;
        var fqId = <%=this.CurFQZC.ID%>;
		$(function(){			
			$('.top-item').each(function(){
				$(this).click(function(){
					$('.top-item').removeClass('active');
					$(this).addClass('active');
					num = $(this).find('input').attr('name');
					$('.submit-money').text(num);
					$('#top-other-button').val("");
				});
			});
			$('#top-other-button').focus(function(){
				$('.top-item').removeClass('active');
				$('.submit-money').text(0);
			})
			$('#top-other-button').on("input propertychange", function(){
				num = $(this).val();
				if($(this).val() != ""){
					$('.submit-money').text(num);
				}else{
					$('.top-item').eq(0).addClass('active');
					num = $('.top-item').eq(0).find('input').attr('name');
					$('.submit-money').text(num);
				}
			})
		})

        function invokeJsApi(apiParam) {
            if (apiParam.length <= 0)
                return;
            WeixinJSBridge.invoke(
                'getBrandWCPayRequest',
                apiParam, //josn串
                function (res) {
                    if (res.err_msg == 'get_brand_wcpay_request:ok') {
                        window.location.href = '<%=this.FQZCViewUrl%>'; //支付前一个页面
                    } else if (res.err_msg == 'get_brand_wcpay_request:cancel') {
                        
                    } else {
                        alert("支付失败:" + res.err_code + res.err_desc + res.err_msg);                        
                    }                    
                }
            );
        }

		function jsApiCall() {
		    var zcRemark = jQuery("#tbZcRemark").val();
            jQuery.ajax({
                url: "<%=this.CreateZcAndPayInfoUrl%>",
                type: 'post', dataType: 'json', timeout: 10000,
                data: { fqId: fqId, zcRemark: zcRemark, paySum: num },
                async: false,
                success: function (apiParam) {
                    if (apiParam != null) {
                        invokeJsApi(apiParam);
                    }
                    else {
                        alert("支付失败！");
                    }
                }
            });

            //document.getElementById("dlgDealing").style.display = 'none';               	           
        }

        // 点“付款”时调用该方法
        function callpay()
        {
            if (typeof WeixinJSBridge == "undefined")
            {
                if (document.addEventListener)
                {
                    document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
                }
                else if (document.attachEvent)
                {
                    document.attachEvent('WeixinJSBridgeReady', jsApiCall);
                    document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
                }
            }
            else
            {
                jsApiCall();
            }
        }
        $('.submit-button').click(function(){
        	callpay();
        });
	</script>

</body>
</html>